﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DBLibrary.Model.pojo
{
    public class PersonLocation : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        private int id;
        private string name;
        private string card;
        private int stationId;
        private string stationName;
        private bool enabled;
        bool isWarning;
        bool isLowVoltage;
        bool isDownHole;
        private double voltage;
        private bool localized;
        private string direction;
        private double distance;

        private string position; 
        private string status="";
        private DateTime updateTime;
        private DateTime arriveTime;
        private bool isDisplay = true;
        public bool IsDownHole
        {
            get
            {
                return isDownHole;
            }
            set
            {
                isDownHole= value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsDownHole"));
                }
            }
        }

        public int DirectionValue
        {
            get
            {
                if (Direction.IndexOf(">") >= 0) //指向井口 ,<--
                    return 0;
                else //指向井下，--> 
                    return 1;
            }
        }

        public bool IsWarning { 
            get => isWarning;
            set { 
                isWarning = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsWarning"));
                }
            } 
        }
        public bool IsLowVoltage { 
            get => isLowVoltage;
            set { 
                isLowVoltage = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsLowVoltage"));
                }
            } 
        }
        public int Id { get => id; set => id = value; }
        public string Name { get => name; set => name = value; }
        public string Card { get => card; set => card = value; }
        public int StationId { get => stationId;
            set
            {
                stationId = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("StationId"));
                }
            }
        }
        public bool Enabled { get => enabled; set => enabled = value; }

        public string IsLowVoltageWarning {
            get {
                if (isLowVoltage)
                    return "低电压";
                else 
                    return "电压正常";
            }
            
        }
        public string IsSOSWarning
        {
            get
            {
                if (IsWarning)
                    return "呼叫报警";
                else
                    return "正常";
            }

        }
        public double Voltage { get => voltage;
            set
            {
                voltage = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Voltage"));
                }
            }
        }
        public bool Localized { get => localized;
            set
            {
                localized = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Localized"));
                }
            }
        }
        public string Direction { get => direction;
            set { 
                direction = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Direction"));
                }
            } 
        }
        public double Distance { get => distance;
            set
            {
                distance = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Distance"));
                }
            }
        }
        public string Position { get => position;
            set
            {
                position = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Position"));
                }
            }
        }
        public DateTime UpdateTime { get => updateTime;
            set
            {
                updateTime = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("UpdateTime"));
                }
            }
        }
        public string Status
        {
            set { 
                status = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Status"));
                }
            }
            get=> status;
        }

        public string StationName { get => stationName;
            set
            {
                stationName = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("StationName"));
                }
            }

        }
        public bool IsDisplay { get => isDisplay; set => isDisplay = value; }
        public DateTime ArriveTime { get => arriveTime;
            set
            {
                arriveTime = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("ArriveTime"));
                }
            }
        }
    }
}
